package ynu.edu.controller;

import org.springframework.web.bind.annotation.*;
import ynu.edu.entity.User;

@RestController
@RequestMapping("/user")
public class UserController {
    @GetMapping("getUserById/{userId}")
    public User getUserById(@PathVariable("userId") Integer userId) {
        User user = new User();
        user.setUserId(userId);
        user.setUserName("provider11001");
        user.setPassword("123456");
        return user;
    }

    @PostMapping("/createUser")
    public User createUser(@RequestBody User user) {
        // 模拟创建用户
        user.setUserId(1); // 假设新用户ID为1
        return user;
    }

    @PutMapping("/updateUser")
    public User updateUser(@RequestBody User user) {
        // 模拟更新用户
        user.setUserName(user.getUserName() + " updated");
        return user;
    }

    @DeleteMapping("/deleteUser/{userId}")
    public String deleteUser(@PathVariable("userId") Integer userId) {
        // 模拟删除用户
        return "User with ID " + userId + " deleted.";
    }
}
